import request from '@/utils/request'

const baseUrl = '/goods/category'

// 查询所有分类--新增修改商品下拉框
export function getCategoryList() {
    return request({
        url: `${baseUrl}/list`,
        method: 'GET'
    })
}

// 列表分页查询接口
export function getPageList(query: GoodsCategoryQuery, current = 1, size = 20) {
    return request({
        url: `${baseUrl}/search`,
        method: 'POST',
        data: {...query, current, size}
    })
}

// 删除
export function deleteById(id: string) {
    return request({
        url: `${baseUrl}/${id}`,
        method: 'DELETE'
    })
}

// 新增
export function add(data: GoodsCategoryType) {
    return request({
        url: `${baseUrl}`,
        method: 'POST',
        data
    })
}

// 修改
export function update(data: GoodsCategoryType) {
    return request({
        url: `${baseUrl}`,
        method: 'PUT',
        data
    })
}